package com.mrzhou.log.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.mrzhou.core.tool.utils.DateUtil;
import com.mrzhou.core.tool.utils.LocalDateUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.Date;

@Getter
@Setter
public class BaseLogEntity {

    @ApiModelProperty(value = "id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @ApiModelProperty(value = "租户id")
    private String tenantId;

    @ApiModelProperty("服务ID")
    private String serverId;

    @ApiModelProperty("服务器名")
    private String serverHost;

    @ApiModelProperty("服务器IP")
    private String serverIp;

    @ApiModelProperty("当前的环境")
    private String env;

    @ApiModelProperty("请求的类型")
    private String method;

    @ApiModelProperty("请求的地址")
    private String requestUri;

    @ApiModelProperty("用户代理")
    private String userAgent;

    @ApiModelProperty("远程ip地址")
    private String remoteIp;

    @ApiModelProperty("方法的类名称")
    private String methodClass;

    @ApiModelProperty("方法名称")
    private String methodName;

    @ApiModelProperty("操作提交的数据, 最好使用json保存")
    private String parameters;

    @ApiModelProperty("链路id")
    private String cloudId;

    @ApiModelProperty("请求时间")
    @DateTimeFormat(pattern = LocalDateUtil.DATE_TIME_FORMAT)
    private LocalDateTime requestTime;


    @ApiModelProperty("创建者")
    private String createBy;

    @ApiModelProperty("创建时间")
    @DateTimeFormat(pattern = LocalDateUtil.DATE_TIME_FORMAT)
    private LocalDateTime createTime;

}
